using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace JBORPG.Net
{
    public class NHType
    {
        private Object m_Instance;
        private Type m_Type;

        public NHType(Type t, NetHandler nh)
        {
            m_Instance = t.Assembly.CreateInstance(t.FullName, false);

            MethodInfo mi = t.GetMethod("SetNetHandler");
            if (mi == null)
                throw new Exception("Handler malformed");

            mi.Invoke(m_Instance, new Object[] { nh });
            m_Type = t;
        }

        public Object Instance
        {
            get
            {
                return m_Instance;
            }
        }

        public Type Type
        {
            get
            {
                return m_Type;
            }
        }
    }
}
